/*
 * @Description:
 * @Version: 2.0
 * @Autor: zhangjx
 * @Date: 2023-05-30 11:58:53
 * @LastEditors: zhangjx
 * @LastEditTime: 2023-06-03 09:28:50
 */
import { useCrudStore } from '@/stores/crud'
import { storeToRefs } from 'pinia'

export default defineComponent({
	name: 'AplidTreeSelect',
	props: {
		filterLabel: {
			type: String,
			default: 'label',
		},
	},
	setup(props) {
		const { menuTreeData } = storeToRefs(useCrudStore())
		const defaultProps = {
			value: 'id',
			label: 'label',
			children: 'children',
		}

		const filterNodeMethod = (value, data) => data[props.filterLabel]!.includes(value)
		return () => (
			<el-tree-select
				class="w-100"
				data={menuTreeData.value}
				props={defaultProps}
				node-key="id"
				check-strictly
				filter-node-method={filterNodeMethod}
				filterable
			/>
		)
	},
})
